<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form method="post" action="{:url('Execorder/save')}" id="addForm">
    <h1>添加订单执行</h1>
    <div class="wizard-card" data-onValidated="setServerName" data-cardname="name">
        <h3><span>订单评审信息</span></h3>

        <div class="wizard-input-section">

            <div class="form-group">
                <label>订单评审号</label>
                <select class="form-control" name="oid" id="oid" onchange="getOid(this.options[this.options.selectedIndex].value)">
                    <option value=""></option>
                    {volist name="orders" id="v"}
                    <option value="{$v.oid}">{$v.oid}</option>
                    {/volist}
                </select>
            </div>
            <div id="fromoid" class="forhid">
                <div class="form-group">
                    <label>国家</label>
                    <input type="text" class="form-control" readonly id="sid" data-validate=""/>
                </div>
                <div class="form-group">
                    <label>客户</label>
                    <input type="text" class="form-control" readonly id="cid" data-validate=""/>
                </div>
                <div class="form-group">
                    <label>基表型号</label>
                    <input type="text" class="form-control" readonly id="meter_id" data-validate=""/>
                </div>
                <div class="form-group">
                    <label>表数量</label>
                    <input type="text" class="form-control" readonly id="order_qty" data-validate=""/>
                </div>
                <div class="form-group">
                    <label>生产状态</label>
                    <input type="text" class="form-control" readonly id="is_status_oid" data-validate=""/>
                </div>
            </div>

        </div>

    </div>

    <div class="wizard-card" data-cardname="group">
        <h3><span>模块信息</span></h3>

        <div class="wizard-input-section">
            <div class="form-group">
                <label>电子模块类型</label>
                <select class="form-control" name="model_id" id="model_id" data-validate="">
                    {volist name="modelTypes" id="v"}
                    <option value="{$v['model_id']}">{$v.model_type}</option>
                    {/volist}
                </select>
            </div>
            <div class="form-group">
                <label>模块订单号</label>
                <input type="text" class="form-control" name="model_num" id="model_num" data-validate=""/>
            </div>
            <div class="form-group">
                <label>模块数量</label>
                <input type="text" class="form-control" name="model_qty" id="model_qty" data-validate=""/>
            </div>
            <div class="form-group">
                <label for="model_start">模块下单开始-结束时间</label>
                <div class="form-group">
                    <span class="input-group-addon new-date-i"><i class="fa fa-calendar"></i></span>
                    <input type="date" id="model_start" name="model_start" class="new-date">
                    <input type="text" placeholder="--" class="new-input">
                    <input type="date" id="model_end" name="model_end" class="new-date">
                </div>

            </div>
        </div>
    </div>

    <div class="wizard-card" data-onload="" data-cardname="location">
        <h3><span>基表信息</span></h3>

        <div class="wizard-input-section">
            <div class="form-group">
                <label>基表订单号</label>
                <input type="text" name="order_num" class="form-control">
            </div>
            <div class="form-group" id="meter_num">
                <label>开始表号-结束表号</label>
                <div class="form-group">
                    <input type="text" name="meter_start" class="new-form-control">
                    <input type="text" placeholder="--" class="new-input">
                    <input type="text" name="meter_end" class="new-form-control">
                </div>
            </div>
            <div class="form-group forhid" id="meter_num_fix">
                <input type="text" id="meter_len" readonly style="border: 0;color: red;width: 100%;">
            </div>
            <div class="form-group">
                <label>基表组装开始-完成时间</label>
                <div class="form-group">
                    <span class="input-group-addon new-date-i"><i class="fa fa-calendar"></i></span>
                    <input type="date" id="assem_start" name="assem_start" class="new-date">
                    <input type="text" placeholder="--" class="new-input">
                    <input type="date" id="assem_end" name="assem_end" class="new-date">
                </div>
            </div>

        </div>
    </div>

    <div class="wizard-card">
        <h3><span>生产信息</span></h3>

        <div class="wizard-input-section">
            <div class="form-group">
                <label>制造商</label>
                <select class="form-control" name="mf_id" id="mf_id" data-validate="">
                    {volist name='manus' id='v'}
                    <option value="{$v['mf_id']}">{$v.manufacturer}</option>
                    {/volist}
                </select>
            </div>
            <div class="form-group">
                <label>生产负责人</label>
                <select class="form-control" name="pid" id="pid" data-validate="">
                    {volist name='principles' id='v'}
                    <option value="{$v['pid']}">{$v.product_principle}</option>
                    {/volist}
                </select>
            </div>
            <div class="form-group">
                <label>客户化工具</label>
                <select class="form-control" name="custom_tool" id="custom_tool">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </div>

            <div class="form-group">
                <label>生产数据校验</label>
                <select class="form-control" name="data_verify" id="data_verify" data-validate="">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </div>
            <div class="form-group">
                <label>发货状态</label>
                <select class="form-control" name="is_status" id="is_status" data-validate="">
                    <option value="1">是</option>
                    <option value="0">否</option>
                </select>
            </div>

        </div>
    </div>


    <div class="wizard-card">
        <h3><span>其他相关信息</span></h3>

        <div class="wizard-input-section">
            <div class="form-group">
                <label>所属业务部门</label>
                <select class="form-control" name="sale_id" id="sale_id">
                    <option value="1">业务一部</option>
                    <option value="2">业务二部</option>
                    <option value="3">业务三部</option>
                    <option value="4">业务四部</option>
                </select>
            </div>
            <div class="form-group">
                <label>订单金额-单位</label>
                <div>
                    <input type="text" name="sum_amounts" id="sum_amounts" class="new-sum">
                    <select name="sum_units" id="sum_units" class="new-units">
                        <option value="$">$</option>
                        <option value="￥">￥</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label>备注</label>
                <input type="text" name="comments" class="form-control" data-validate="">
            </div>

        </div>
    </div>
    <button type="submit">确定</button>

</form>
<script src="__JS__/jquery.js"></script>
<script type="text/javascript">
    //根据订单评审id展示相关信息
    function getOid(oid) {
        $('#fromoid').removeClass('forhid')
        $.post("{:url('Order/one')}",{oid:oid},function(data){
            //console.log(data);
            if(data) {
                $('#meter_id').val(data[0].meter_type)
                $('#cid').val(data[0].client);
                $('#sid').val(data[0].state);
                $('#is_status_oid').val(data[0].status);
                $('#order_qty').val(data[0].order_qty);
                var meterLen = data[0].meter_len;
                //如果没有表号长度
                if(meterLen != 0){
                    $('#meter_num_fix').removeClass('forhid')
                    $('#meter_len').val('请输入 '+meterLen+' 位表号')
                }else{
                    $('#meter_num_fix').removeClass('forhid')
                    $('#meter_len').val('请输入 10,11,12或13 位表号')
                }
            }
        },'json');
    }


</script>
</body>
</html>